#include<stdio.h>
#include<string.h>
#define MAX_LEN 1002

int islegal(int arr[],int N){
	int j=0,top=0;
	int x = 1,y = arr[j];
	int stack[MAX_LEN];
	while(x<N || j<=N){
		if(y == 0)
			return 1;
		if(y==x){
			x++;
			y = arr[++j];
	   	}else if(top > 0 && y == stack[top-1]){
			top--;
			y = arr[++j];
	   	}else if(x < N){
			stack[top++] = x++;
	   	}else{
			return 0;
		}
	}
	return 0;
}

int main(){
	int arr[MAX_LEN], N ,i;
	while(scanf("%d",&N),N){
		while(scanf("%d",&arr[0]),arr[0]){
			for(i = 1;i < N;i++){
				scanf("%d",&arr[i]);
			}
			arr[N] = 0;
		    if(islegal(arr,N+1)){
				printf("Yes\n");
		    }else{
				printf("No\n");
		   	}
	   }
	   printf("\n");
	}
	return 0;
}